Imports NUnit.Framework
Imports pixolut.BizBlox


<TestFixture()> Public Class SQLGrouperTests

    Public Sub New()
        MyBase.New()
    End Sub

    <TestFixtureSetUp()> Public Sub GlobalInit()
        '        Setup.CreateDataSet()
    End Sub

    <TestFixtureTearDown()> Public Sub GlobalDestruct()
        '       Setup.ClearDataSet()
    End Sub

    <SetUp()> Public Sub LocalInit()

    End Sub

    <TearDown()> Public Sub LocalDestruct()

    End Sub

    <Test()> Public Sub testGroupTermsAND()
        Dim al As New ArrayList
        al.Add("a")
        al.Add("b")
        Dim out As String = SQLGrouper.GroupTerms(al, SQLGrouper.LOGIC.LOGIC_AND)
        Assert.IsTrue(out.IndexOf("((a) AND (b))") > -1)
        Console.WriteLine(out)
    End Sub

    <Test()> Public Sub testGroupTermsOR()
        Dim al As New ArrayList
        al.Add("a")
        al.Add("b")
        Dim out As String = SQLGrouper.GroupTerms(al, SQLGrouper.LOGIC.LOGIC_OR)
        Assert.IsTrue(out.IndexOf("((a) OR (b))") > -1)
        Console.WriteLine(out)
    End Sub

    <Test()> Public Sub testGroupTermStart()
        Dim out As String = SQLGrouper.GroupTerm("testTable", "a", "b", False, SQLGrouper.GROUPING.GROUP_START)
        Assert.IsTrue(out.IndexOf("(testTable a 'b%')") > -1)
        Console.WriteLine(out)
    End Sub

    <Test()> Public Sub testGroupTermEnd()
        Dim out As String = SQLGrouper.GroupTerm("testTable", "a", "b", False, SQLGrouper.GROUPING.GROUP_END)
        Assert.IsTrue(out.IndexOf("(testTable a '%b')") > -1)
        Console.WriteLine(out)
    End Sub

    <Test()> Public Sub testGroupTermExact()
        Dim out As String = SQLGrouper.GroupTerm("testTable", "a", "b", False, SQLGrouper.GROUPING.GROUP_EXACT)
        Assert.IsTrue(out.IndexOf("(testTable a 'b')") > -1)
        Console.WriteLine(out)
    End Sub

    <Test()> Public Sub testGroupTermMid()
        Dim out As String = SQLGrouper.GroupTerm("testTable", "a", "b", False, SQLGrouper.GROUPING.GROUP_MID)
        Assert.IsTrue(out.IndexOf("(testTable a '%b%')") > -1)
        Console.WriteLine(out)
    End Sub


    <Test()> Public Sub testGroupAllPermutations()
        Dim out As String = SQLGrouper.GroupAllPermutations("testTable", "a", "x", False)
        Console.WriteLine(out)
        Assert.IsTrue(out.IndexOf("(testTable a '%x%')") > -1)
        Assert.IsTrue(out.IndexOf("(testTable a '%x')") > -1)
        Assert.IsTrue(out.IndexOf("(testTable a 'x%')") > -1)
        Assert.IsTrue(out.IndexOf("(testTable a 'x')") > -1)
    End Sub

End Class
